<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title></title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <%@ include file="/WEB-INF/jsp/common/js.jsp"%>

    <script>
        function changePswd(){
            if($('#oldPswd').val()==''){
                $('#message').html('旧密码不能为空!');
                return;
            }
            if($('#newPswd').val()==''){
                $('#message').html('新密码不能为空!');
                return;
            }
            if($('#newPswd').val().length < 6 || $('#newPswd').val().length > 20){
                $('#message').html('新密码长度请限制在6-20之间!');
                return;
            }
            if($('#confirmPswd').val()==''){
                $('#message').html('确认密码不能为空!');
                return;
            }
            if($('#confirmPswd').val() != $('#newPswd').val()){
                $('#message').html('新密码和确认密码不一致!');
                return;
            }
            if($('#oldPswd').val() == $('#newPswd').val()){
                $('#message').html('新密码和旧密码不允许一致!');
                return;
            }
            var url = '<%=request.getContextPath()%>/devops/account/changePswd';
            var data = {newPswd:$('#newPswd').val(),oldPswd:$('#oldPswd').val()};
            JSendAjax(url,data);
        }

        function JCollBack(_data){
            if(_data.success){
                alert("修改成功，请重新登录!")
                window.location = '<%=request.getContextPath()%>/';
                return;
            }
            $('#message').html(_data.msg);
        }
    </script>
</head>
<body>
<div class="container">
    <h1>修改密码</h1>

    <div style="width: 50%">
        <form method="post" >
            <div class="form-group">
                <label>旧密码</label>
                <input name="oldPswd" id="oldPswd" type="password" class="form-control shortInput" placeholder="旧密码"  value="${po.password}">
            </div>
            <div class="form-group">
                <label>新密码</label>
                <input name="newPswd" id="newPswd" type="password" class="form-control shortInput" placeholder="新密码"  value="${po.password}">
            </div>
            <div class="form-group">
                <label>确认密码</label>
                <input name="confirmPswd" id="confirmPswd" type="password" class="form-control shortInput" placeholder="确认密码"  value="${po.password}">
            </div>
            <button type="button" class="btn btn-default" onclick="changePswd()">保存</button>
            <button type="reset" class="btn btn-default">重置</button>
        </form>
    </div>
    <div class="form-group">
        <span style="color: red;font-size: 16px" id="message"></span>
    </div>
</div>
</body>
</html>
